HTML Full Course [Day 4] [Hindi] πŸ’» | Table, Nested Table, Style πŸš€ | Mohit Decodes

HTML Tutorial – Part 4: Tables, Styling & Nesting

Welcome to Part 4 of the HTML Full Course by Mohit Decodes! In this lesson, you’ll learn how to present structured data using HTML tables, apply basic styling, and even nest tables inside tables.

πŸ“‹ HTML Tables

HTML tables allow you to organize data in rows and columns using a structured format.

βœ… Basic Table Tags:

  1. <table> – Starts the table
  2. <tr> – Table row
  3. <th> – Table header (bold and centered by default)
  4. <td> – Table data cell

πŸ“Œ Example:

html
CopyEdit
<table border="1">
<tr>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td>Mohit</td>
<td>30</td>
</tr>
<tr>
<td>Aarav</td>
<td>25</td>
</tr>
</table>

🎨 HTML Table Styling

You can enhance the look of a table using inline styles or CSS.

πŸ“Œ Example with Inline Style:

html
CopyEdit
<table style="width: 50%; border-collapse: collapse;" border="1">
<tr style="background-color: #f2f2f2;">
<th>Name</th>
<th>City</th>
</tr>
<tr>
<td>Mohit</td>
<td>Delhi</td>
</tr>
<tr>
<td>Aarav</td>
<td>Mumbai</td>
</tr>
</table>

βœ… Style Tips:

  1. Use border-collapse: collapse; to merge borders
  2. Set padding for spacing
  3. Use background colors for readability

🧩 Nested HTML Tables

A nested table is a table placed inside a cell (<td>) of another table. This is useful when you want to display complex data or group related data together.

πŸ“Œ Example:

html
CopyEdit
<table border="1">
<tr>
<td>
Outer Table - Cell 1
<table border="1">
<tr>
<td>Nested Table - Cell 1</td>
<td>Nested Table - Cell 2</td>
</tr>
</table>
</td>
<td>Outer Table - Cell 2</td>
</tr>
</table>

πŸ“ Note: Avoid overusing nested tables for layout. Instead, use CSS Flexbox or Grid for modern layouts.